package com.android.rapidcash.activitys

import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.util.TypedValue
import android.widget.TextView
import com.android.lib.base.baseclass.BaseVMActivity
import com.android.lib.base.ext.click
import com.android.rapidcash.viewmodel.MainViewModel
import com.blankj.utilcode.util.ClipboardUtils
import com.blankj.utilcode.util.PhoneUtils
import com.blankj.utilcode.util.ToastUtils
import com.rapidcash.abanca.santander.vivus.revolut.waylet.libertex.icmarkets.caixabank.R
import com.rapidcash.abanca.santander.vivus.revolut.waylet.libertex.icmarkets.caixabank.databinding.ActivityCustomerServiceBinding


class CustomerServiceActivity : BaseVMActivity<MainViewModel, ActivityCustomerServiceBinding>() {

    override fun initView(savedInstanceState: Bundle?) {

    }

    override fun initData() {
        viewModel.getAppValueList()
    }

    override fun initListener() {
        mBinding.ivBack.click { finish() }
    }

    override fun initObserve() {
        viewModel.getAppValueList.observe(this) {
            it.spanishAnyoneGreedyKiteImmediateLab.forEach { phone ->
                val text = TextView(this)
                text.setTextColor(Color.parseColor("#ff666666"))
                text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14.toFloat())
                text.text = phone.ableBossActualShip
                text.click { PhoneUtils.dial(text.text.toString()) }
                mBinding.ll2.addView(text)
            }
            it.privateFortunateUnemploymentTeamwork.forEach { phone ->
                val text = TextView(this)
                text.setTextColor(Color.parseColor("#ff666666"))
                text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14.toFloat())
                text.text = phone.ableBossActualShip

                text.click {
                    ClipboardUtils.copyText(text.text.toString()).also {
                        ToastUtils.showShort(getString(R.string.copy))
                    }
                    val intent = Intent(Intent.ACTION_VIEW)
                    val data = Uri.parse("mailto:?subject=${text.text}")
                    intent.data = data
                    startActivity(intent)
                }
                mBinding.ll4.addView(text)
            }
            it.cordlessRemarkCollege.forEach { phone ->
                val text = TextView(this)
                text.setTextColor(Color.parseColor("#ff666666"))
                text.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14.toFloat())
                text.text = phone.ableBossActualShip
                text.click {
                    ClipboardUtils.copyText(text.text.toString()).also {
                        ToastUtils.showShort(getString(R.string.copy))
                    }
                    val url = "https://api.whatsapp.com/send?phone=${text.text}"
                    val intent = Intent(Intent.ACTION_VIEW)
                    intent.data = Uri.parse(url)
                    startActivity(intent)
                }
                mBinding.ll3.addView(text)
            }
            mBinding.tvInfo.text = it.nextRegards
        }
    }


}